\c spqr-console

-- check that numeric type works
CREATE DISTRIBUTION ds1 COLUMN TYPES integer;
CREATE KEY RANGE krid1 FROM 1 ROUTE TO sh1 FOR DISTRIBUTION ds1;
CREATE KEY RANGE krid2 FROM 11 ROUTE TO sh2 FOR DISTRIBUTION ds1;
ALTER DISTRIBUTION ds1 ATTACH RELATION xxmixed DISTRIBUTION KEY id;

\c regress

CREATE TABLE xxmixed(id int);
INSERT INTO xxmixed (id) VALUES(1);
INSERT INTO xxmixed (id) VALUES(10);
INSERT INTO xxmixed (id) VALUES(11);
INSERT INTO xxmixed (id) VALUES(20);

INSERT INTO xxmixed (id) VALUES(21);
INSERT INTO xxmixed (id) VALUES(22);
INSERT INTO xxmixed (id) VALUES(29);
INSERT INTO xxmixed (id) VALUES(30);

SELECT * FROM xxmixed ORDER BY id;
SELECT * FROM xxmixed WHERE id <= 10 ORDER BY id;
SELECT * FROM xxmixed WHERE id <= 20 ORDER BY id;
SELECT * FROM xxmixed WHERE id <= 30 ORDER BY id;

SELECT * FROM xxmixed WHERE id BETWEEN 1 AND 25 ORDER BY id;
SELECT * FROM xxmixed WHERE id BETWEEN 13 AND 18 ORDER BY id;
SELECT * FROM xxmixed WHERE id BETWEEN 19 AND 30 ORDER BY id;
SELECT * FROM xxmixed WHERE id BETWEEN 21 AND 22 ORDER BY id;
SELECT * FROM xxmixed WHERE id BETWEEN 22 AND 30 ORDER BY id;

DROP TABLE xxmixed;

\c spqr-console

-- check that uuid type works
CREATE DISTRIBUTION ds2 COLUMN TYPES varchar;
CREATE KEY RANGE krid3 FROM 00000000-0000-0000-0000-000000000000 ROUTE TO sh1 FOR DISTRIBUTION ds2;
CREATE KEY RANGE krid4 FROM 88888888-8888-8888-8888-888888888888 ROUTE TO sh2 FOR DISTRIBUTION ds2;
ALTER DISTRIBUTION ds2 ATTACH RELATION xxmixeduuid DISTRIBUTION KEY id;

\c regress
CREATE TABLE xxmixeduuid(id uuid);
INSERT INTO xxmixeduuid (id) VALUES('00000000-0000-0EA0-0FAB-AB031389FF09');
INSERT INTO xxmixeduuid (id) VALUES('FA98123B-0000-0EA0-0FAB-AB031389FF09');
INSERT INTO xxmixeduuid (id) VALUES('1234AAAA-98AB-0000-0000-BCAD0192EFEF');
INSERT INTO xxmixeduuid (id) VALUES('FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFE');
INSERT INTO xxmixeduuid (id) VALUES('00000000-0000-0000-0000-000000000000');

SELECT * FROM xxmixeduuid WHERE id > '00000000-0000-0000-0000-000000000000' ORDER BY id;
SELECT * FROM xxmixeduuid WHERE id >= '00000000-0000-0000-0000-000000000000' ORDER BY id;
SELECT * FROM xxmixeduuid WHERE id >= '88888888-8888-8888-8888-888888888888' ORDER BY id;
SELECT * FROM xxmixeduuid WHERE id <= 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFE' ORDER BY id;

DROP TABLE xxmixeduuid;

\c spqr-console
DROP DISTRIBUTION ALL CASCADE;
DROP KEY RANGE ALL;